#ifndef BTL_EXTRA_GUI_QOSGWIDGET
#define BTL_EXTRA_GUI_QOSGWIDGET

#include <QtOpenGL/QGLWidget>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QTimer>
#include <osg/Config>
#include <osgViewer/Viewer>
#include <osgViewer/GraphicsWindow>
#include <osgViewer/api/X11/GraphicsWindowX11>

namespace btl
{
namespace extra
{
namespace gui
{

class QOSGWidget : public osgViewer::Viewer, public QGLWidget
{
   public:
      QOSGWidget(
         QWidget* parent = 0,
         const QGLWidget* shareWidget = 0,
         Qt::WindowFlags flags = 0
      );

      virtual ~QOSGWidget(void);

   protected:

      virtual void paintGL(void);

      virtual void resizeGL(int width, int height);

      virtual void keyPressEvent(QKeyEvent* e);

      virtual void keyReleaseEvent(QKeyEvent* e);

      virtual void mouseMoveEvent(QMouseEvent* e);

      virtual void mousePressEvent(QMouseEvent* e);

      virtual void mouseReleaseEvent(QMouseEvent* e);

      osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;
};

} //namespace gui
} //namespace extra
} //namespace btl

namespace btl
{
namespace extra
{

using gui::QOSGWidget;

} //namespace extra
} //namespace btl

#endif //BTL_EXTRA_GUI_QOSGWIDGET
